package com.iss.umservice.dao.impl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.iss.umservice.bean.AnnouncementNoReadQueryBean;
import com.iss.umservice.bean.AnnouncementReadBean;
import com.iss.umservice.bean.AnnouncementReadedQueryBean;
import com.iss.umservice.bean.AnnouncementReadedResultBean;
import com.iss.umservice.bean.AnnouncementReadedResultSummaryBean;
import com.iss.umservice.dao.AnnouncementreadDao;

@Repository
public class AnnouncementreadDaoImpl extends SqlMapClientDaoSupport implements
		AnnouncementreadDao {

	@Override
	public List<AnnouncementNoReadQueryBean> queryNoReadAnn(String currUserId,
			int offset, int row) {
		return getSqlMapClientTemplate().queryForList(
				"announcementreadquery.query_noReadAnn", currUserId, offset,
				row);
	}

	@Override
	public List<AnnouncementReadedQueryBean> queryReadedAnn(String currUserId,
			int offset, int row) {
		return getSqlMapClientTemplate().queryForList(
				"announcementreadquery.query_readedAnn", currUserId, offset,
				row);
	}

	@Override
	public int countNoReadAnn(String currUserId) {
		return (Integer) getSqlMapClientTemplate().queryForObject(
				"announcementreadquery.get_noReadAnnCount", currUserId);
	}

	@Override
	public int countReadedAnn(String currUserId) {
		return (Integer) getSqlMapClientTemplate().queryForObject(
				"announcementreadquery.get_readedAnnCount", currUserId);
	}

	@Override
	public int addReadedAnn(AnnouncementReadBean newReadAnn) {
		return (Integer) getSqlMapClientTemplate().insert(
				"announcementread.add_announcementread", newReadAnn);
	}

	@Override
	public AnnouncementReadBean getReadedAnn(int annId, String currUserId) {
		AnnouncementReadBean re = new AnnouncementReadBean();
		re.setAnnid(annId);
		re.setUserid(currUserId);
		re = (AnnouncementReadBean) getSqlMapClientTemplate().queryForObject(
				"announcementread.get_announcementread", re);
		return re;
	}

	@Override
	public List<AnnouncementReadedResultBean> queryReadedAnnResult(
			AnnouncementReadedResultBean bean, int offset, int row) {
		return getSqlMapClientTemplate().queryForList(
				"announcementreadquery.query_readedAnnResult", bean, offset,
				row);
	}

	@Override
	public int countReadedAnnResult(AnnouncementReadedResultBean bean) {
		return (Integer) getSqlMapClientTemplate().queryForObject(
				"announcementreadquery.query_readedAnnResultCount", bean);
	}

	@Override
	public List<AnnouncementReadedResultSummaryBean> queryReadedAnnResultSummary(AnnouncementReadedResultSummaryBean bean) {
		return getSqlMapClientTemplate().queryForList(
				"announcementreadquery.query_readedAnnResultSummary",bean);
	}

}
